$(document).ready(function() {
	var list=[];
	//初始化菜单
    $.ajax({  
        type: 'POST',
        dataType: "json",
        url:path + '/systemMenu/system',
        success: function(data){
            $.each(data.data,function(i,n){
                $('#navMenu').accordion('add',{
                    id:n.id,
                    title: n.label,
                    selected: i==0?true:false,
                    content:'<ul id="tree'+i+'"></ul>',
                    iconCls:'icon-tip',
                });
                list[i]=n.children;
            });
        }
    });
        
    $('#navMenu').accordion({
        onSelect: function(title,index){
            var p = $('#navMenu').accordion('getSelected');
        	var id = p.attr("id");
        	var temp=list[index-1];
        	var data=[];
        	$.each(temp,function(i,n){
        		var e = {"id":n.id,"text":n.label,"url":n.url,"attributes":{"buttons":n.children}};
        		data[i]=e;
        	});
        	$("ul[id='tree"+(index-1)+"']").tree({
//               url:strurl + '/treelist?id='+id,	
        		 //data:p.attr("child"),
        		data:data,
                onClick:function(node){
                	 addPanel(path, node.id,node.text,node.url,node.attributes);
                }
            });
        }
    });
    
});